﻿
@{
    Layout = null;
    var BM = ViewBag.BM as SGArchiveSystem7xDB.T_Deparetment;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>@SGArchiveSystem7xCommons.SGWebInfo._sAppTitle</title>

    <!-- Global stylesheets -->
    <link href="~/Content/FrameUI/css/icons/icomoon/styles.css" rel="stylesheet" type="text/css">
    <link href="~/Content/FrameUI/css/bootstrap.css" rel="stylesheet" type="text/css">
    <link href="~/Content/FrameUI/css/core.css" rel="stylesheet" type="text/css">
    <link href="~/Content/FrameUI/css/components.css" rel="stylesheet" type="text/css">
    <link href="~/Content/FrameUI/css/colors.css" rel="stylesheet" type="text/css">
    <!-- /global stylesheets -->
    <!-- Core JS files -->
    <script type="text/javascript" src="~/Content/FrameUI/js/plugins/loaders/pace.min.js"></script>
    <script type="text/javascript" src="~/Content/FrameUI/js/core/libraries/jquery.min.js"></script>
    <script type="text/javascript" src="~/Content/FrameUI/js/core/libraries/bootstrap.min.js"></script>
    <script type="text/javascript" src="~/Content/FrameUI/js/plugins/loaders/blockui.min.js"></script>
    <!-- /core JS files -->
    <!-- Theme JS files -->
    <script type="text/javascript" src="~/Content/FrameUI/js/plugins/visualization/d3/d3.min.js"></script>
    <script type="text/javascript" src="~/Content/FrameUI/js/plugins/visualization/d3/d3_tooltip.js"></script>
    <script type="text/javascript" src="~/Content/FrameUI/js/plugins/forms/styling/switchery.min.js"></script>
    <script type="text/javascript" src="~/Content/FrameUI/js/plugins/forms/styling/uniform.min.js"></script>
    <script type="text/javascript" src="~/Content/FrameUI/js/plugins/forms/selects/bootstrap_multiselect.js"></script>
    <script type="text/javascript" src="~/Content/FrameUI/js/plugins/ui/moment/moment.min.js"></script>
    <script type="text/javascript" src="~/Content/FrameUI/js/plugins/pickers/daterangepicker.js"></script>
    <script type="text/javascript" src="~/Content/FrameUI/js/core/app.js"></script>
    <script type="text/javascript" src="~/Content/FrameUI/js/pages/dashboard.js"></script>
    <!-- /theme JS files -->
</head>
<body class="navbar-bottom">
    <!-- Main navbar -->
    <div class="navbar navbar-inverse">
        <div class="navbar-header">
            <a class="navbar-brand">档案管理系统</a>
        </div>
        <div class="navbar-collapse collapse" id="navbar-mobile">
            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown dropdown-user">
                    <a class="dropdown-toggle" data-toggle="dropdown">
                        <img src="~/Content/Images/user.png" alt="">
                        <span>欢迎您：@BM.Dep_Name &nbsp; @ViewBag.UName （@ViewBag.BmName）</span>
                        <i class="caret"></i>
                    </a>
                </li>
            </ul>
        </div>
    </div>
    <!-- /main navbar -->
    <!-- Page container -->
    <div class="page-container">
        <!-- Page content -->
        <div class="page-content">
            <!-- Main sidebar -->
            <!-- /main sidebar -->
            <!-- Main content -->
            <div class="content-wrapper">
                <!-- Page header -->
                <div class="page-header page-header-default" style="margin-bottom:0px">
                    <div class="breadcrumb-line">
                        <ul class="breadcrumb">
                            <li><a href="#"><i class="icon-home2 position-left"></i><span id="Main_Index_Big"></span></a></li>
                            <li class="active"><span id="Main_Index_Small">@ViewBag.vi</span></li>
                        </ul>
                    </div>
                </div>
                <div style="margin-top:5px;margin-left:5px;margin-right:5px">
                    <center>
                        <div class="modal-content" style="width:50%">
                            <div class="modal-header">
                                <h3 class="modal-title pull-left">修改密码</h3>
                            </div>
                            <div class="modal-body">
                                <div class="form-group">
                                    <label for="name" class="pull-left">新密码：</label>
                                    <input style="width:100%" class="form-control" label="新密码:" type="password" labelwidth="70px" labelalign="right" id="Main_ChangePwd_txtPwd1" />
                                </div>
                                <div class="form-group">
                                    <label for="name" class="pull-left">确认密码：</label>
                                    <input style="width:100%" label="确认密码:" class="form-control" type="password" labelwidth="70px" labelalign="right" id="Main_ChangePwd_txtPwd2" />
                                </div>
                                <h7><span style="color:red">@ViewBag.info</span></h7>
                            </div>

                            <div class="modal-footer">
                                <button class="btn btn-primary" onclick="ModifyPwd()">确认修改</button>
                            </div>
                        </div>
                    </center>
                </div>
            </div>
            <!-- /main content -->
        </div>
        <!-- /page content -->
    </div>
    <!-- /page container -->
    <!-- Footer -->
    <div class="navbar navbar-default navbar-fixed-bottom">
        <ul class="nav navbar-nav no-border visible-xs-block">
            <li><a class="text-center collapsed" data-toggle="collapse" data-target="#navbar-second"><i class="icon-circle-up2"></i></a></li>
        </ul>
        <div class="navbar-collapse collapse" id="navbar-second">
            <div class="navbar-right">
                <div class="navbar-text">
                    当前日期: @System.DateTime.Now.ToString("yyyy 年 M 月 d 日")
                </div>
            </div>
        </div>
    </div>
    <script>
        //判断输入密码的类型
        function CharMode(iN) {
            if (iN >= 48 && iN <= 57) //数字
                return 1;
            if (iN >= 65 && iN <= 90) //大写
                return 2;
            if (iN >= 97 && iN <= 122) //小写
                return 4;
            else
                return 8;
        }
        //bitTotal函数
        //计算密码模式
        function bitTotal(num) {
            modes = 0;
            for (i = 0; i < 4; i++) {
                if (num & 1) modes++;
                num >>>= 1;
            }
            return modes;
        }
        //返回强度级别
        function checkStrong(sPW) {
            if (sPW.length < 8)
                return 0; //密码太短，不检测级别
            Modes = 0;
            for (i = 0; i < sPW.length; i++) {
                //密码模式
                Modes |= CharMode(sPW.charCodeAt(i));
            }
            return bitTotal(Modes);
        }

        function ModifyPwd() {
            var p1 = $('#Main_ChangePwd_txtPwd1').val();
            var p2 = $('#Main_ChangePwd_txtPwd2').val();
            if (p1 != p2)
                alert('两次输入的密码不一致!');
            else {
                var v = checkStrong(p1);
                if (v == 0)
                    alert('密码长度不够!');
                else if (v < 3)
                    alert('密码强度不够!');
                else {
                    $.ajax({
                        url: '/Main/btnSavePassword',
                        type: 'post',
                        dataType: "text",
                        data: { old: '', pwd: p1 },
                        success: function (data) {
                            if (data == '1') {
                                alert('提示: 修改密码成功,请重新登录系统!');
                                window.location.href = '/Login/Index';
                            }
                            else if (data == '-1')
                                alert('提示: 修改失败!');
                            else if (data == '0')
                                alert('提示: 旧密码错误!');
                        }
                    })
                }
            }
        }
    </script>
</body>
</html>




